#ifndef SINGLETON_H
#define SINGLETON_H

#include <iostream>

template< class T >
class Singleton
{
protected:
	Singleton() {}
	virtual ~Singleton() {}
public:
	static T* get()
	{
		if ( !sm_Instance ) {
			std::cout << "Creating new singleton instance." << std::endl;
			sm_Instance = new T();
		}
		
		//static T instance = T();
		//return &instance;
		return sm_Instance;
	}
private:
	static T* sm_Instance;
};

template< class T >
T* Singleton<T>::sm_Instance = 0;

#endif //SINGLETON_H
